// pages/detail/index.js
var router = require('../../utils/router/index.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    listData: [
      { "data1": "口罩", "data2": "100", "data3": "2019/01/01" , "data4": "上海xx集团" , "data5": "详情" },
      { "data1": "防护服", "data2": "100", "data3": "2019/01/01" , "data4": "上海xx集团" , "data5": "详情" },
      { "data1": "消毒水", "data2": "100", "data3": "2019/01/01" , "data4": "上海xx集团" , "data5": "详情" }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.get_hospital_by_id()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  
  /**
   * 更新今日库存
   */
  bind_hospital_count: function(){
    router.push({ 
      name: 'hospital_count',
      data: {
        ads: ''
        } 
      })
  },
  bind_hospital_use: function(){
    router.push({ 
      name: 'hospital_use',
      data: {
        ads: ''
        } 
      })
  },

  bind_hospital_edit_info: function(){
    router.push({ 
      name: 'hospital_edit_info',
      data: {
        ads: ''
        } 
      })
  },

  /**
   * 医院详情详情页数据
   */
  get_hospital_by_id: function(){
    wx.cloud.callFunction({
      // 云函数名称
      name: 'hospital',
      // 传给云函数的参数
      data:{
        "action": "get_hospital_by_id",
        "id": "d68532785e3abde00ac306ee4178e9e3"
      }
    })
    .then(res => {
      console.log(res.result.data) // 3
    })
    .catch(console.error);
  }
})